<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - Bootstrap Table</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="/admin/favicon.ico">
    <link href="/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/admin/css/animate.css" rel="stylesheet">
    <link href="/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/admin/css/animate.css" rel="stylesheet">

    <style>
        a{
            color:#777;
        }
    </style>

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
            <div class="row row-lg">
            <div class="col-sm-12">
                <!-- Example Events -->
                <div class="example-wrap">
                    <div class="example">
                        <div class="btn-group hidden-xs" id="tabtar" role="group">
                            <button type="button" class="btn btn-primary" onclick="add()">
                                <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
                            </button>
                        </div>
                        <table id="table" data-toggle='table' data-height="500">
                            <thead>
                                <tr>
                                    <th data-field="state" data-checkbox="true"></th>
                                    <th data-sortable='true'>ID</th>
                                    <th>图片</th>
                                    <th>创建时间</th>
                                    <th>更新时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($banner as $v)
                                <tr>
                                    <td></td>
                                    <td>{{$v->id}}</td>
                                    <td><img src="/admin/images/banner/{{$v->img_slug}}"></td>
                                    <td>{{$v->updated_at}}</td>
                                    <td>{{$v->created_at}}</td>
                                    <td>
                                        <a href="javascript:;" class='glyphicon glyphicon-pencil' title='修改' onclick="edit({{$v->id}})"></a>
                                        <a href="javascript:;" class='glyphicon glyphicon-trash' title='删除' onclick="del(this,{{$v->id}})"></a>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- End Example Events -->
            </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <script src="/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="/admin/js/content.js?v=1.0.0"></script>


    <!-- Bootstrap table -->
    <script src="/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

    <!-- Peity -->
    <script src="/admin/js/demo/bootstrap-table-demo.js"></script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> -->
    <!--统计代码，可删除-->
    <script src="/admin/js/plugins/layer/layer.min.js"></script>
     <script>
        $('#table').bootstrapTable({
            // search:true,
            // showRefresh:true,
            // showColumns:true,
            // showToggle:true,
            pagination:true,
            pageSize:'5',
            iconSize:'outline',
            toolbar: '#tabtar',
        });

        //添加
        function add(){
            layer.open({
                type: 1,
                title: '添加轮播图片',
                maxmin: true,
                shadeClose: true, //点击遮罩关闭层
                area : ['600px' , '400px'],
                // content: '/admin/carousel/add'
                content: '<div class="wrapper wrapper-content animated fadeInRight"><div class="col-sm-12"><div class="ibox float-e-margins"><div class="ibox-content" style="border:0"><form action="/admin/carousel/insert" method="post" class="form-horizontal m-t" id="signupForm" enctype="multipart/form-data"><input type="hidden" name="_token" value="{{ csrf_token() }}"><div class="col-md-12"><div class="form-group"><label class="col-sm-3 control-label">图片：</label><div class="col-sm-9"><input type="file" name="img" class="form-control" value="+ 浏览上传"><span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 图片尺寸：500*500</span></div></div></div><div class="form-group"><div class="col-sm-8 col-sm-offset-3"><button class="btn btn-primary" type="submit">提交</button></div></div></form></div></div></div></div>'
            });
        }


        // 无刷新删除跳转
        function del(a,id){
            layer.confirm("确定删除么?",{
                btn: ['确定','取消']
            },function(){
                $.ajax({
                    url:"{{url('/admin/carousel/del')}}",
                    type:"GET",
                    data:{"id":id},
                    success:function(data){
                        if(data == 1){
                            layer.msg('删除成功', {icon: 1});
                            $(a).parents().parents("tr").remove();
                        }else{
                             layer.msg('删除失败', {icon: 2});
                        }
                    }
                });
            },function(){
                layer.msg('已取消', {icon: 2});
            });
        }

        // 修改
        function edit(id){
            layer.open({
                type: 1,
                title: '修改轮播图片',
                maxmin: true,
                shadeClose: true, //点击遮罩关闭层
                area : ['600px' , '400px'],
                content: '<body class=""><div class="wrapper wrapper-content animated fadeInRight"><div class="col-sm-12"><div class="ibox float-e-margins"><div class="ibox-content" style="border:0"><form action="/admin/carousel/update" method="post" class="form-horizontal m-t" id="signupForm" enctype="multipart/form-data"><input type="hidden" name="id" value="'+id+'"><input type="hidden" name="_token" value="{{ csrf_token() }}"><div class="col-md-12"><div class="form-group"><label class="col-sm-3 control-label">图片：</label><div class="col-sm-9"><input type="file" name="img" class="form-control" value=""><span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 图片尺寸：500*500</span></div></div></div><div class="form-group"><div class="col-sm-8 col-sm-offset-3"><button class="btn btn-primary" type="submit">提交</button></div></div></form></div></div></div></div>'
                // cancel:function(){
                //     layer.msg('取消修改',{'icon':2});
                // }
            });
        }
    </script>

</body>

</html>
